Skip to content

[SSF-126]: Recurring donations backend#98

Open
dburkhart07 wants to merge 13 commits intomainfrom
ddb/SSF-126-recurring-donations-backend
Open

[SSF-126]: Recurring donations backend#98
dburkhart07 wants to merge 13 commits intomainfrom
ddb/SSF-126-recurring-donations-backend

Conversation

@dburkhart07
Copy link

ℹ️ Issue

Closes #126

📝 Description

This PR was a simple backend update to fix makes donations support reoccurances. We had an implementation suggested in the ticket, which I followed pretty closely. I also made a migration for these changes, ensuring that all fields were considered nullable, until the reoccurance field became somehting other than once.

I also altered the backend create endpoint accordingly. I made it so that, if the recurrance type is not ONCE, then all 3 other fields need to be filled out, or we cannot create a donation.

The idea with this migration now, is that we can easily implement recurruing donations as follows

  • On the frontend side: When a manufacturer puts in the information of the recurrance type, how often, and the specific days of the week/day of the month/day of the year, we will use this to calculate our very first nextDonationDates array
  • From there, we will implement a continuous check to see whether or not our first element in the array (since it will be the most recent) is the current date. If it is, we will send an email alert, and remove that. We will then use todays date, as well as the recurrance type and frequency, to calculate when the next date will be for the donation, and add that to the end of the array
  • We will also decrease the number of occurances when this happens. If the number of occurances becomes 0, then we do not add to the array anymore (we could also potentially delete the donation as well).

✔️ Verification

  • Tested that the migration and revert both worked
  • Error tested the new create endpoint with proper details

🏕️ (Optional) Future Work / Notes

Now that we have this, we need to being handling actually updating the endpoint daily. This will include the following:

  • We will need to implement all of the above flow in the description later on. This should likely be reference for whoever goes to implement it, as this future logic is what the current entity is based on.

Copy link
Member

@amywng amywng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you spell recurrence wrong in every single place 😭

@dburkhart07 dburkhart07 requested a review from amywng February 5, 2026 01:55
@dburkhart07 dburkhart07 requested a review from amywng February 5, 2026 03:54
@dburkhart07 dburkhart07 requested a review from amywng February 6, 2026 05:27
@dburkhart07 dburkhart07 requested a review from amywng February 6, 2026 15:34
Copy link
Member

@amywng amywng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last couple things!

example: ['2024-07-01T00:00:00Z', '2024-08-01T00:00:00Z'],
nullable: true,
},
occurencesRemaining: { type: 'integer', example: 2, nullable: true },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

occurrence has two r's...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i hate replace all

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a replace all issue

@dburkhart07 dburkhart07 requested a review from amywng February 6, 2026 15:52
@Min(0.01)
totalEstimatedValue: number;

@IsEnum(RecurrenceEnum)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recurrenceFreq: number | undefined,
nextDonationDates: Date[] | undefined,
occurrencesRemaining: number | undefined,
): Promise<Donation> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just pass the entire dto

enumName: 'donations_status_enum',
default: DonationStatus.AVAILABLE,
})
status: DonationStatus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add ! to the rest of the required fields

@IsEnum(RecurrenceEnum)
recurrence: RecurrenceEnum;

@IsNumber()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think instead of IsOptional you can use ValidateIf

},
body: CreateDonationDto,
): Promise<Donation> {
if (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that we have the dto idt we need this validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants